package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.annotation.RequiresPermissionsDesc;
import com.qf.pojo.DtsOrder;
import com.qf.service.DtsOrderService;
import com.qf.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lixu
 */
@RestController
@RequestMapping("/admin/order")
@CrossOrigin
public class OrderController {

    @Autowired
    private DtsOrderService dtsOrderService;

    /**
     * 订单列表
     * - 接口地址 : http://localhost:8083/admin/order/list?page=1&limit=20&sort=add_time&order=desc
     *
     * - 下行数据 :
     */
    @RequiresPermissionsDesc(menu = {"商场管理","订单管理"},button = "查询")
    @RequiresPermissions(value = "admin:brokerage:list")
    @GetMapping("/list")
    public Object list(Integer page,Integer limit,String sort,String order,String username){
        IPage<DtsOrder> ipage = dtsOrderService.findPage(page,limit,sort,order);
        Map data = new HashMap<>();
        data.put("total",ipage.getTotal());
        data.put("items",ipage.getRecords());
        return ResponseUtil.ok(data);
    }
}
